package zut.edu.cs.network.practice8;

import java.util.Calendar;
import java.util.Date;

public class Employee extends Person{
	Date hireDay;
	double salary;
	public Date getHireDay() {
		return hireDay;
	}
	public double getSalary() {
		return salary;
	}
	public Employee(String name, double salary,int year,int month ,int day) {
		super(name);
		Calendar calendar=Calendar.getInstance();
		calendar.set(year, month, day);
		this.hireDay=calendar.getTime();
		this.salary = salary;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((hireDay == null) ? 0 : hireDay.hashCode());
		long temp;
		temp = Double.doubleToLongBits(salary);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Employee other = (Employee) obj;
		if (hireDay == null) {
			if (other.hireDay != null)
				return false;
		} else if (!hireDay.equals(other.hireDay))
			return false;
		if (Double.doubleToLongBits(salary) != Double.doubleToLongBits(other.salary))
			return false;
		if (name != other.name)
			return false;
		return true;
	}
	public String getDescription() {
		return name+", an employee with salary of $"+salary;		
	}
	public void raiseSalary(double addsalary){
		this.salary+=addsalary;
	}
	@Override
	public String toString() {
		return "Employee [hireDay=" + hireDay + ", salary=" + salary + ", name=" + name + "]";
	}
	
}
